home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
COMMUNIC
/
H399.ZIP
/
ODY200SH.LZH
/
BIG.SCR
next >
Wrap
Text File
|
1989-09-15
|
9KB
|
283 lines
/* This file is here to serve as a more substantial example of an Odyssey
script. It is probably not directly useful to you unless you use the UK
CIX system in association with a PD offline reader program called Query.
*/
SCRIPT getcix;
VAR mailw,nomsgs,MailPrompt,MainPrompt,ReadPrompt,SubSystem:Number;
GotMail,GotMessages:Flag;
f:File;
Conf,Msgno,Line:String;
/*.............................................*/
Func Login():Flag;
Var ReDials:Number;
CIXok:Flag;
Id,Password:String;
Begin
ClrScr();
Write("█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█|");
Write("█ Calling CIX via Direct Dial █|");
Write("█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█|");
IF FetchStr("CIX",Id,Password) THEN
ReDials:=0; CIXok:=FALSE;
REPEAT
CASE Redials % 3 OF
0:IF Dial("CIX1") THEN CIXok:=TRUE; END;
| 1:IF Dial("CIX2") THEN CIXok:=TRUE; END;
| 2:IF Dial("CIX3") THEN CIXok:=TRUE; END;
END;
IF CIXok THEN
IF WaitFor("login:",10) THEN
Paste("qix");
ELSE
HangUp(); CIXok:=FALSE;
END;
END;
IF NOT CIXok THEN
INC(Redials);
IF Redials=10 THEN
Write("Could not connect to CIX|");
RETURN FALSE;
END;
Delay(5);
END;
UNTIL CIXok;
WaitFor("user) "); Transmit(Id);
WaitFor("Password:"); Transmit(Password);
RETURN TRUE;
ELSE
Write("|Failed to find Id and Password.|");
RETURN FALSE;
END;
End; /* Login */
/*.............................................*/
Proc ChangeSubSystem(sys:Number);
Begin
IF SubSystem<>sys THEN
IF SubSystem<>MainPrompt THEN Paste("q"); WaitFor("Main:"); END;
IF sys=MailPrompt THEN
Paste("mail"); WaitFor("Mail:"); Delay(1);
END;
SubSystem := sys;
END;
End; /* ChangeSubSystem */
/*.............................................*/
Proc SendMail();
Begin
ChangeSubSystem(MailPrompt);
IF FEOF(f) THEN RETURN; END;
Paste("to "+line); WaitFor("Enter subject: ");
FRead(f,line);
IF Pos("SUBJECT:",line)=0 THEN
Paste(SubStr(line,8,80));
WaitFor(".<CR>");
ELSE
Paste(""); WaitFor(".<CR>"); WaitFor(">",4); Paste(line);
END;
WHILE NOT FEOF(f) DO
WaitFor(">",4);
FRead(f,line); Paste(line);
IF line="." THEN
WaitFor("send/action:"); Paste("send");
WaitFor("Mail:");
RETURN;
END;
END;
End; /* SendMail */
/*.............................................*/
Proc AddMessage();
Begin
WaitFor("Add/action:"); Paste("a");
WaitFor("Read:");
End; /* AddMessage */
/*.............................................*/
Proc SendComment();
Begin
ChangeSubSystem(ReadPrompt);
Paste("join "+Conf); WaitFor("Read:");
Paste("hea "+Msgno+" com");
WaitFor(".<CR>");
WHILE NOT FEOF(f) DO
WaitFor(">",4);
FRead(f,line); Paste(line);
IF line="." THEN AddMessage(); RETURN; END;
END;
End; /* SendComment */
/*.............................................*/
Proc SayMessage();
Begin
ChangeSubSystem(ReadPrompt);
IF FEOF(f) THEN RETURN; END;
Paste("join "+Conf); WaitFor("Read:");
Paste("say"); WaitFor("TITLE:");
FRead(f,line);
IF Pos("TITLE:",line)=0 THEN
Paste(SubStr(line,6,80));
WaitFor(".<CR>");
ELSE
Paste(""); WaitFor(".<CR>"); WaitFor(">",4); Paste(line);
END;
WHILE NOT FEOF(f) DO
WaitFor(">",4);
FRead(f,line); Paste(line);
IF line="." THEN AddMessage(); RETURN; END;
END;
End; /* SayMessage */
/*.............................................*/
Proc CheckReply();
Var MsgCount:Number;
Begin
MsgCount:=0;
IF IsFile("REPLY.BSC") THEN
FOpen(f,"REPLY.BSC");
FRead(f,line);
IF line<>"#begin" THEN
Write("REPLY.BSC not a valid reply file|");
FClose(f);
RETURN;
END;
WHILE NOT FEOF(f) DO
IF NOT OnLine() THEN
Write("Line lost after ",MsgCount," messages were|");
Write("successfully uploaded.|");
Exit();
END;
FRead(f,line);
IF Pos("#m|",line)=0 THEN (* a mail message *)
(* line has typical format: #m|cixid *)
line := SubStr(line,3,80);
SendMail();
ELSIF Pos("#c|",line)=0 THEN (* a comment *)
(* line has typical format: #c|conf/topic|1234 *)
line := SubStr(line,3,80);
conf := SubStr(line,0,Pos("|",line));
msgno := SubStr(line,Length(conf)+1,5);
SendComment();
ELSIF Pos("#s|",line)=0 THEN (* say, ie originate a message *)
(* line has typical format: #s|conf/topic *)
conf := SubStr(line,3,80);
SayMessage();
ELSIF Pos("#e|",line)=0 THEN (* end of message *)
(* line has typical format: #e|1234 *)
INC(MsgCount);
msgno := SubStr(line,3,80);
Paste("hea sk to "+msgno); WaitFor("Read:");
ELSIF Pos("#end",line)=0 THEN (* end of command file *)
FClose(f);
ChangeSubSystem(MainPrompt);
FDelete("REPLY.BSC");
RETURN; /* success */
ELSIF Pos("#r|",line)=0 THEN (* resign from a conf/topic *)
(* line has typical format: #r|conf/topic *)
ChangeSubSystem(MainPrompt);
Paste("resign "+SubStr(line,3,80));
WaitFor("Main:");
ELSIF Pos("#f|",line)=0 THEN (* fixup CIX message pointers *)
(* line has typical format: #f|conf/topic|1234 *)
line := SubStr(line,3,80);
conf := SubStr(line,0,Pos("|",line));
msgno := SubStr(line,Length(conf)+1,5);
Paste("join "+Conf); WaitFor("Read:");
Paste("sk to "+Msgno); WaitFor("Read:");
ELSE
Write("?? Error in REPLY.BSC format.|");
FClose(f);
ChangeSubSystem(MainPrompt);
RETURN;
End;
End;
Write("Unexpected end of REPLY.BSC file.|");
FClose(f);
ChangeSubSystem(MainPrompt);
FDelete("REPLY.BSC");
END;
End; /* CheckReply */
/*.............................................*/
Proc CheckMessages();
Begin
IF GotMessages THEN
/* if there are messages then download them */
ChangeSubSystem(MainPrompt);
Delay(1);
Paste("file read all");
WaitFor("Main:"); Delay(1);
END;
End; /* CheckMessages */
/*.............................................*/
Proc CheckMail();
Begin
IF GotMail THEN
ChangeSubSystem(MailPrompt);
Paste("file all");
WaitFor("No new messages waiting");
WaitFor("Mail:");
Delay(1);
Paste("Clear inbask quick"); WaitFor("Mail:");
Paste("Clear outbask quick"); WaitFor("Mail:");
END;
End; /* CheckMail */
/*.............................................*/
Proc DoDownload();
Begin
IF GotMessages OR GotMail THEN
Paste("opt down z, q"); WaitFor("Main:");
Paste("download");
WaitFor("OK to delete"); Delay(2); Paste("");
WaitFor("Main:");
END;
End; /* DoDownload */
/*.............................................*/
BEGIN
IF Login() THEN
mailw := WatchFor("unread mail");
nomsgs := WatchFor("No new messages.");
When("More ?","|");
WaitFor("Main:");
GotMail := Received(mailw);
GotMessages := NOT Received(nomsgs);
ClrWatch(mailw);
ClrWatch(nomsgs);
Paste("opt term pagelength 0 q");
WaitFor("Main:");
MainPrompt:=0; ReadPrompt:=1; MailPrompt:=2;
SubSystem := MainPrompt;
CheckReply();
CheckMessages();
CheckMail();
ChangeSubSystem(MainPrompt);
DoDownload();
Delay(1);
Paste("bye");
WaitFor("Goodbye",5);
Halt();
END;
END;